(function() {
	Wallet.widget.AccountRecordCategoryPanel = function(el, config) {
		config = config || {};
		
		Wallet.lang.applyIf(config, {
			fixedCenter: true,
			constrainToViewport: true,
			modal: true,
			width: "320px"
		});
		Wallet.widget.AccountRecordCategoryPanel.superclass.constructor.call(this, el, config);	
	};
	
	var Lang = YAHOO.lang,
		Dom = YAHOO.util.Dom,
		Panel = YAHOO.widget.Panel,
		CustomEvent = YAHOO.util.CustomEvent,
		AccountRecordCategoryPanel = Wallet.widget.AccountRecordCategoryPanel;
	
	var EVENT_TYPES = {        
		"VALUE_SUBMIT": "valueSubmit"
    }
    
    AccountRecordCategoryPanel.OK_BUTTON_CSS = "category-ok-button";
    AccountRecordCategoryPanel.INPUT_CSS = "category-input";
    
	Lang.extend(AccountRecordCategoryPanel, Panel, {
		initEvents: function () {
            AccountRecordCategoryPanel.superclass.initEvents.call(this);
            var SIGNATURE = CustomEvent.LIST;
        
            this.valueSubmitEvent = this.createEvent(EVENT_TYPES.VALUE_SUBMIT);
            this.valueSubmitEvent.signature = SIGNATURE;
		},
		
		init: function (el, userConfig) {
            AccountRecordCategoryPanel.superclass.init.call(this, el/*, userConfig*/); 
            this.beforeInitEvent.fire(AccountRecordCategoryPanel);
        
            if (userConfig) {
                this.cfg.applyConfig(userConfig, true);
            }
        
            this.initComponents();
            this.initListeners();
        
            this.initEvent.fire(AccountRecordCategoryPanel);
        },
        initComponents: function() {
        	var btnEl = Dom.getElementsByClassName(AccountRecordCategoryPanel.OK_BUTTON_CSS, "button", this.body)[0];
        	this.okButton = new YAHOO.widget.Button(btnEl);
        	
        	var inputEl = Dom.getElementsByClassName(AccountRecordCategoryPanel.INPUT_CSS, "input", this.body)[0];
        	this.inputEl = inputEl;
        },
        initListeners: function() {
        	this.okButton.addListener("click", this.onEventOkButtonClick, this);
        },
        onEventOkButtonClick: function(evt, data) {        	
        	var panel = data;
        	panel.fireEvent(EVENT_TYPES.VALUE_SUBMIT, panel.inputEl.value);
        	panel.hide();
        }
	});
}());
